package com.yswy.backstage.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yswy.backstage.dto.req.PackageManageAddUpdateVo;
import com.yswy.backstage.dto.req.PackageManageListVo;
import com.yswy.backstage.dto.req.TgChannleListVo;
import com.yswy.backstage.entity.user.User;
import com.yswy.backstage.service.PackageManageService;
import com.yswy.backstage.service.TgChannleChildCodeService;
import com.yswy.backstage.service.TgChannleChildService;
import com.yswy.backstage.service.TgChannleService;
import com.yswy.domain.entity.PackageManage;
import com.yswy.domain.entity.TgChannle;
import com.yswy.domain.entity.TgChannleChild;
import com.yswy.domain.entity.TgChannleChildCode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

import static com.yswy.backstage.utils.GldTokenUtils.getUser;

@RestController
@RequestMapping("/channle")
@ApiModel("平台扣量")
public class TgChannleController {

    @Autowired
    private TgChannleService tgChannleService;
    @Autowired
    private TgChannleChildService tgChannleChildService;
    @Autowired
    private TgChannleChildCodeService tgChannleChildCodeService;

    @PostMapping("/listTgChannle")
    @ApiOperation(value = "平台列表")
    public Page<TgChannle> listTgChannle(@RequestBody @Validated TgChannleListVo filter, HttpServletRequest request) {
        return tgChannleService.listTgChannle(filter);
    }

    @PostMapping("/addOrUpdateTgChannle")
    @ApiOperation(value = "添加或修改平台")
    public void addOrUpdateTgChannle(@RequestBody @Validated TgChannle filter, HttpServletRequest request) {
        tgChannleService.addOrUpdateTgChannle(filter ,getUser(request));
    }

    @GetMapping("/delTgChannle")
    @ApiOperation(value = "删除平台")
    public void delTgChannle(@RequestParam(value = "id") Long id, HttpServletRequest request) {
        tgChannleService.delTgChannle(id ,getUser(request));
    }

    @PostMapping("/listTgChannleChild")
    @ApiOperation(value = "平台子列表")
    public Page<TgChannleChild> listTgChannleChild(@RequestBody @Validated TgChannleListVo filter, HttpServletRequest request) {
        return tgChannleChildService.listTgChannleChild(filter);
    }

    @PostMapping("/addOrUpdateTgChannleChild")
    @ApiOperation(value = "添加或修改平台子列表")
    public void addOrUpdateTgChannleChild(@RequestBody @Validated TgChannleChild filter, HttpServletRequest request) {
        tgChannleChildService.addOrUpdateTgChannleChild(filter ,getUser(request));
    }

    @GetMapping("/delTgChannleChild")
    @ApiOperation(value = "删除平台子列表")
    public void delTgChannleChild(@RequestParam(value = "id") Long id, HttpServletRequest request) {
        tgChannleChildService.delTgChannleChild(id ,getUser(request));
    }

    @PostMapping("/listTgChannleChildCode")
    @ApiOperation(value = "扣量配置列表")
    public Page<TgChannleChildCode> listTgChannleChildCode(@RequestBody @Validated TgChannleListVo filter, HttpServletRequest request) {
        return tgChannleChildCodeService.listTgChannleChildCode(filter);
    }

    @PostMapping("/addOrUpdateTgChannleChildCode")
    @ApiOperation(value = "添加或修改扣量配置")
    public void addOrUpdateTgChannleChildCode(@RequestBody @Validated TgChannleChildCode filter, HttpServletRequest request) {
        tgChannleChildCodeService.addOrUpdateTgChannleChildCode(filter ,getUser(request));
    }

    @GetMapping("/delTgChannleChildCode")
    @ApiOperation(value = "删除扣量配置")
    public void delTgChannleChildCode(@RequestParam(value = "id") Long id, HttpServletRequest request) {
        tgChannleChildCodeService.delTgChannleChildCode(id ,getUser(request));
    }
}



